package cwb1;

import java.util.Map;

public class AchievementFactory {

	//Amount flag, this is a total of studied hours.
	public final static long AMOUNT = 1;
	//Duration flag this is a non-stop duration of an activity.
	public final static long DURATION = 2;
	//Statistic flag.
	public final static long DISTINCTION = 3;
	//Regularity flag.
	public final static long REGULARITY = 4;
	//Special flag.
	public final static long SPECIAL = 5;
	
	/**
	 * The constructor is private. You are not allowed to make an object of this class.
	 */
	private AchievementFactory()
	{
		
	}
	
	/**
	 * Creates the right type of achievement, using a Map with the properties.
	 * 
	 * @param properties The properties of the kind of achievement.
	 * @return The right kind of achievement corresponding the type of the given achievement.
	 */
	public static Achievement createAchievement(Map<String,Object> properties) {
		Achievement achievement = null;
		if(properties.get("achievementType").equals(AMOUNT)) {
			Amount amount = new Amount(properties);
			achievement = amount;
		}
		
		else if(properties.get("achievementType").equals(DURATION)) {
			Duration duration = new Duration(properties);
			achievement = duration;
		}
		
		else if(properties.get("achievementType").equals(DISTINCTION)) {
			Distinction distinction = new Distinction(properties);
			achievement = distinction;
		}
		
		else if(properties.get("achievementType").equals(REGULARITY)) {
			Regularity regularity = new Regularity(properties);
			achievement = regularity;
		}
		
		else if(properties.get("achievementType").equals(SPECIAL)) {
			Special special = new Special(properties);
			achievement = special;
		}
		
		return achievement;
		
	}
}
